import http from "@/http/index.ts"
import {
    ElectricalControlClassification,
    ElectricalControlClassificationListParam,
    ElectricalControlMaterial,
    ElectricalControlMaterialListParam,
    ElectricalMachinery,
    ElectricalMachineryQuery
} from '@/api/electrical/type.ts'

// 分类相关API
// ----------------------------------------

// 新增分类
export const addClassificationApi = (data: ElectricalControlClassification) => {
    return http.post("/electrical/createClassification", data)
}

// 分页条件查询分类列表
export const getClassificationListApi = (data: ElectricalControlClassificationListParam) => {
    return http.get("/electrical/getClassificationList", data)
}

// 编辑分类
export const editClassificationApi = (data: ElectricalControlClassification) => {
    return http.put("/electrical/updateClassification", data)
}

// 删除分类
export const deleteClassificationApi = (id: number) => {
    return http.delete(`/electrical/deleteClassification/${id}`)
}

// 获取分类精简列表
export const getSimpleClassificationListApi = () => {
    return http.get("/electrical/simpleClassificationList")
}

// 材料相关API
// ----------------------------------------

// 新增材料
export const addMaterialApi = (data: ElectricalControlMaterial) => {
    return http.post("/electrical/createMaterial", data)
}

// 分页条件查询材料列表
export const getMaterialListApi = (data: ElectricalControlMaterialListParam) => {
    return http.get("/electrical/getMaterialList", data)
}

// 编辑材料
export const editMaterialApi = (data: ElectricalControlMaterial) => {
    return http.put("/electrical/updateMaterial", data)
}

// 删除材料
export const deleteMaterialApi = (id: number) => {
    return http.delete(`/electrical/deleteMaterial/${id}`)
}

// 导出材料模板
export const exportMaterialTemplateApi = () => {
    return http.get("/electrical/exportMaterialTemplate", {}, { responseType: 'blob' })
}

// 导出材料数据
export const exportMaterialApi = (data: ElectricalControlMaterialListParam) => {
    return http.get("/electrical/exportMaterial", data, { responseType: 'blob' })
}

// 导入材料数据
export const importMaterialApi = (file: FormData) => {
    return http.post("/electrical/importMaterial", file, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 电气机械相关API
// ----------------------------------------

// 获取电气机械列表
export const getElectricalMachineryList = (data: ElectricalMachineryQuery) => {
    return http.get("/electrical/getElectricalMachineryList", data)
}

// 获取电气机械详情
export const getElectricalMachineryDetail = (id: number) => {
    return http.get(`/electrical/getElectricalMachinery/${id}`)
}

// 新增电气机械
export const addElectricalMachinery = (data: ElectricalMachinery) => {
    return http.post("/electrical/createElectricalMachinery", data)
}

// 修改电气机械
export const updateElectricalMachinery = (data: ElectricalMachinery) => {
    return http.put("/electrical/updateElectricalMachinery", data)
}

// 删除电气机械
export const deleteElectricalMachinery = (id: number) => {
    return http.delete(`/electrical/deleteElectricalMachinery/${id}`)
} 